﻿$(document).ready(function() {
    $(".thead").wrap("<thead></thead>");
    $(".tfoot").wrap("<tfoot></tfoot>");
    $("#ctl00_MainContent_TJTable").children("tbody").before($("thead"));
    $("#ctl00_MainContent_TJTable").children("tbody").after($("tfoot"));
    $("#ctl00_MainContent_TJTable").tablesorter({ headers: {
        0: { sorter: false },
        1: { sorter: "currency" },
        2: { sorter: "currency" },
        3: { sorter: "currency" },
        4: { sorter: "currency" },
        5: { sorter: "currency" },
        6: { sorter: "currency" },
        7: { sorter: "currency" },
        8: { sorter: "currency" }
    }
    });
    $("#ctl00_MainContent_dropDW").removeAttr("onchange");
    $("#ctl00_MainContent_dropDW").bind("change", function() {
        $(this).children().each(function() {
            if ($(this).attr("selected") != "") {
                var ishh = $(this).attr("value").split('★')[1];
                var ssdw = $(this).attr("value").split('★')[0];
                var jsjb = "";
                var urlattr = $("#ctl00_MainContent_HiddenField2").attr("value").split('◇');
                for (var i = 0; i < urlattr.length - 1; i++) {
                    if (urlattr[i].split('★')[0] == ssdw) {
                        jsjb = urlattr[i].split('★')[1];
                    }
                }
                if (ishh == "0") {//本系统内的单位
                    if ($("#ctl00_MainContent_HiddenField3").val() != ssdw) {//选择单位跟当前单位不一致
                        $("#ctl00_MainContent_BtnQuery").attr("disabled", "disabled");
                        $("#ctl00_MainContent_BtnBack").attr("disabled", "disabled");
                        setTimeout('__doPostBack(\'ctl00$MainContent$dropDW\',\'\')', 0);
                    }
                }
                else if (ishh == "1") {//本系统之外的单位
                    $("#ctl00_MainContent_HiddenField3").val("1");
                    setTimeout(jsjb, 0);
                }
                else {//请选择
                    if ($("#ctl00_MainContent_HiddenField3").val() != "1") {
                        $("#ctl00_MainContent_HiddenField3").val("");
                        $("#ctl00_MainContent_BtnQuery").attr("disabled", "disabled");
                        $("#ctl00_MainContent_BtnBack").attr("disabled", "disabled");
                        setTimeout('__doPostBack(\'ctl00$MainContent$dropDW\',\'\')', 0);
                    }
                }
            }
        })
    })
});

function popWin(selectAction, Title) {
    setTimeout(
                      function() {
                          ymPrompt.win({ message: selectAction
                          + "&StartTime=" + $("#ctl00_MainContent_txtBTime").val()
                          + "&EndTime=" + $("#ctl00_MainContent_txtETime").val(),
                              width: 560,
                              height: 500,
                              title: Title,
                              handler: null,
                              maxBtn: true,
                              minBtn: true,
                              iframe: true
                          });
                      }, 50);
    return false;
}
function yanzheng(type) {

    if ($("#ctl00_MainContent_txtBTime").val() == "") {
        $("#ctl00_MainContent_txtBTime").css("background-color", "plum");
        alert("起始时间不能为空");
        return false;
    }
    else {
        $("#ctl00_MainContent_txtBTime").css("background-color", "");
    }
    if ($("#ctl00_MainContent_txtETime").val() == "") {
        $("#ctl00_MainContent_txtETime").css("background-color", "plum");
        alert("截止时间不能为空");
        return false;
    }
    else {
        $("#ctl00_MainContent_txtETime").css("background-color", "");
    }

    var b = false;
    $("#ctl00_MainContent_dropDW").children().each(function() {
        if ($(this).attr("selected") != "") {
            var ishh = $(this).attr("value").split('★')[1];
            var ssdw = $(this).attr("value").split('★')[0];
            var jsjb = "";
            var urlattr = $("#ctl00_MainContent_HiddenField2").attr("value").split('◇');
            for (var i = 0; i < urlattr.length - 1; i++) {
                if (urlattr[i].split('★')[0] == ssdw) {
                    jsjb = urlattr[i].split('★')[1];
                }
            }
            if (ishh == "1") {
                setTimeout(jsjb, 0);
            }
            else {
                if (type == "1") {
                    $("#ctl00_MainContent_BtnQuery").attr("disabled", "disabled");
                    $("#ctl00_MainContent_BtnBack").attr("disabled", "disabled");
                }
                b = true;
            }
        }
    });
    return b;
}